using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Fan.Dongping.Common
{
    public class BaseConfig
    {
        static string baseConfigFilePath, configXmlFilePath;

        static BaseConfig()
        {
            baseConfigFilePath = AppDomain.CurrentDomain.BaseDirectory + @"\bin\Base.cfg";
            configXmlFilePath = GetConfigXmlFilePathFromBaseConfigFile();
        }

        public static string BaseConfigFilePath
        {
            get
            {
                return baseConfigFilePath;
            }
            set
            {
                baseConfigFilePath = value;
            }
        }

        public static string ConfigXmlFilePath
        {
            get
            {
                return configXmlFilePath;
            }
            set
            {
                configXmlFilePath = value;
            }
        }

        private static string GetConfigXmlFilePathFromBaseConfigFile()
        {
            try
            {
                string[] ss = File.ReadAllLines(BaseConfigFilePath);
                return ss[0];
            }
            catch
            {
                return null;
            }
        }

        public static void SaveToFile()
        {
            File.WriteAllText(baseConfigFilePath, configXmlFilePath);
        }
    }
}
